package co.yixiang.modules.shop.rest.Arest;

import co.yixiang.logging.aop.log.Log;
import co.yixiang.modules.shop.service.YxStoreCategoryService;
import co.yixiang.modules.shop.service.YxStoreProductService;
import co.yixiang.modules.shop.service.dto.YxStoreCategoryDto;
import co.yixiang.modules.shop.service.dto.YxStoreCategoryQueryCriteria;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "Api2:商城:商品分类")
@RestController
@RequestMapping("api2/yxStoreCategory")
public class AStoreCategoryController  extends ABaseController  {

    @Autowired
    private YxStoreCategoryService yxStoreCategoryService;
    @Autowired
    private YxStoreProductService yxStoreProductService;

    @ApiOperation(value = "查询商品分类")
    @GetMapping(value = "/yxStoreCategory")
    public ResponseEntity getYxStoreCategorys(YxStoreCategoryQueryCriteria criteria) {
        List<YxStoreCategoryDto> categoryDTOList = yxStoreCategoryService.queryAll(criteria);
        return new ResponseEntity(yxStoreCategoryService.buildTree(categoryDTOList), HttpStatus.OK);
    }


}
